﻿using MiniFox.Platform.Applications.Models;
using MiniFox.Resources;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;

namespace Sys.Core.Models.Dto
{
    [JsonObject]
    public class ModuleDto
    {
        [JsonProperty("moduleId")]
        [Key]
        public string? ModuleID { get; set; }

        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [JsonProperty("appId")]
        public string ApplicationID { get; set; }

        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [StringLength(30, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        [JsonProperty("moduleName")]
        public string ModuleName { get; set; }

        [StringLength(200, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [JsonProperty("uri")]
        public string Uri { get; set; }

        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [JsonProperty("isPublic")]
        public bool IsPublic { get; set; }

        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [JsonProperty("enabled")]
        public bool Enabled { get; set; }

        [StringLength(100, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        [JsonProperty("queryString")]
        public string? QueryString { get; set; }

        [StringLength(200, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        [JsonProperty("icon")]
        public string? Icon { get; set; }

        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [JsonProperty("openMode"), JsonConverter(typeof(StringEnumConverter))]
        public OpenMode OpenMode { get; set; }

    }
}